<template>
  <el-container class="container">
    <el-aside :width="isCollapsed ? '64px' : '200px'" style="transition: width 0.3s">
    <el-menu
        :default-active="activeMenu"
        class="el-menu-vertical-demo"
        background-color="#333"
        text-color="#fff"
        active-text-color="#ffd04b"
        :collapse="isCollapsed"
    >
      <el-menu-item index="1">
        <el-icon><House /></el-icon>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-sub-menu index="2">
        <template #title>用户管理</template>
        <el-menu-item index="2-1">用户列表</el-menu-item>
        <el-menu-item index="2-2">添加用户</el-menu-item>

      </el-sub-menu>
      <el-sub-menu index="2-3">
        <template #title>用户设置</template>
        <el-menu-item index="2-3-1">权限设置</el-menu-item>
        <el-menu-item index="2-3-2">账号设置</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="2-4">
        <template #title>板块设置</template>
        <el-menu-item index="3-1">分区设置</el-menu-item>
        <el-menu-item index="3-2">板块设置</el-menu-item>
      </el-sub-menu>
    </el-menu>

    </el-aside>
    <!-- 主内容区 -->
    <el-container class="content">
      <el-header style="background-color: #409eff; color: white;">
        <el-button type="primary" @click="toggleCollapse" icon="el-icon-s-fold">
          {{ isCollapsed ? '展开菜单' : '折叠菜单' }}
        </el-button>
      </el-header>
      <el-main>
        <h2>这里是主内容区域</h2>
        <p>在这里可以显示详细的内容或组件。</p>
      </el-main>
    </el-container>
  </el-container>




</template>

<script setup>
import { ref } from "vue";
import {House, User} from "@element-plus/icons-vue";

const activeMenu = ref("1");  // 默认选中的菜单项
const isCollapsed = ref(false);  // 控制侧栏的折叠状态

function toggleCollapse() {
  isCollapsed.value = !isCollapsed.value;
}
</script>

<style scoped>
/* 布局容器 */
.container {
  display: flex;
  height: 100vh; /* 全屏高度 */
}

/* 左侧导航栏样式 */
.el-menu-vertical-demo {
  width: 200px;
  background-color: #333;
  color: #fff;
  height: 100%;
  padding-top: 20px;
}

/* 右侧内容区样式 */
.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f5f5f5;
}
</style>
